﻿using OneOfAll.Common.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace OneOfAll.UserControls
{
    /// <summary>
    /// ConstructionControl.xaml 的交互逻辑
    /// </summary>
    public partial class ConstructionControl : UserControl
    {
        public ConstructionModel Info
        {
            get { return (ConstructionModel)GetValue(InfoProperty); }
            set { SetValue(InfoProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Info.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty InfoProperty =
            DependencyProperty.Register("Info", typeof(ConstructionModel), typeof(ConstructionControl), new PropertyMetadata(null));



        public bool IsSelected
        {
            get { return (bool)GetValue(IsSelectedProperty); }
            set { SetValue(IsSelectedProperty, value); }
        }

        // Using a DependencyProperty as the backing store for IsSelected.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty IsSelectedProperty =
            DependencyProperty.Register("IsSelected", typeof(bool), typeof(ConstructionControl), new PropertyMetadata(false, (sender, e) =>
            {
                var dp = sender as ConstructionControl;
                if (dp == null) return;
                dp.SelectedChanged();
            }));

        private void SelectedChanged()
        {
            if (IsSelected)
                Canvas.SetZIndex(this, 1);
            else
                Canvas.SetZIndex(this, 0);
        }

        public ConstructionControl()
        {
            InitializeComponent();
        }
    }
}
